package m.jclecai.com.adapter.lotteryNumberMenu;


import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.ViewGroup;

import java.util.List;

import m.jclecai.com.R;
import m.jclecai.com.adapter.base.RyAdapter;
import m.jclecai.com.adapter.holder.lotteryNumberMenu.LotteryNumberHolder;
import m.jclecai.com.bean.LotteryNumberMenuBean;
import m.jclecai.com.bean.MissDataBean;
import m.jclecai.com.listener.OnBallCheckedListener;

/**
 * Created by zed on 2018/3/19.
 * 数字菜单每行的适配器
 */

public class LotteryNumberAdapter extends RyAdapter<LotteryNumberHolder> {
    //菜单数据 和 此适配器绑定
    List<LotteryNumberMenuBean> menuBean;
    Context mContext;
    int defCheckMenu = 0;
    RecyclerView.RecycledViewPool viewPool;
    //遗漏
    MissDataBean missDataBean;
    //是否显示遗漏
    boolean isShowMissData = true;

    public LotteryNumberAdapter(List<LotteryNumberMenuBean> menuBean, Context mContext) {
        this.menuBean = menuBean;
        this.mContext = mContext;
        viewPool = new RecyclerView.RecycledViewPool();
    }

    @Override
    public LotteryNumberHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new LotteryNumberHolder(inflate(mContext, R.layout.item_show_number_line, parent, false));
    }

    @Override
    public void onBindViewHolder(LotteryNumberHolder holder, int position) {
        holder.rvNumLine.setRecycledViewPool(viewPool);
        holder.init(defCheckMenu, menuBean.get(defCheckMenu), position, mOnBallCheckedListener);
        holder.setShowMissData(isShowMissData);
        holder.setMissDataBean(missDataBean);
    }

    @Override
    public int getItemCount() {
        return menuBean.get(defCheckMenu).getItemCount();
    }

    public void setDefCheckMenu(int defCheckMenu) {
        this.defCheckMenu = defCheckMenu;
        notifyDataSetChanged();
    }

    public OnBallCheckedListener mOnBallCheckedListener;

    public void setOnBallCheckedListener(OnBallCheckedListener onBallCheckedListener) {
        mOnBallCheckedListener = onBallCheckedListener;
    }

    public void setMissDataBean(MissDataBean missDataBean) {
        this.missDataBean = missDataBean;
        notifyDataSetChanged();
    }

    public void setShowMissData(boolean isShowMissData) {
        if (this.isShowMissData != isShowMissData) {
            this.isShowMissData = isShowMissData;
            notifyDataSetChanged();
        }
    }
}
